﻿<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	 var    $base;
   	 var    $css;

	 
	public function index()
	{
		
		log_message('debug', 'Category Controller Initialized');
		$this->load->model('sub_category_model');
		$this->load->model('book_model');
		$this->load->model('tag_model');
		//Get all sub category
        $categories = $this->sub_category_model->getSubCategoryAll();
        //Get all information of book
        $books = $this->getAllBook();
        
		$this->base = $this->config->item('base_url');
	    $this->css = $this->config->item('css');
		$data['css'] = $this->css;
	    $data['base'] = $this->base;
	    $data['categories'] = $categories;
	    $data['books'] = $books;
	    
		$this->load->view('index', $data);
		
	}
	
	
	function getAllBook()
	{
		$dataBooks = array();
		$books = $this->book_model->getBookAll();
		$count = 0;
		foreach ($books as $row)
		{
			$row['tag'] = $this->tag_model->getTagByBookId($row['book_id']);
			$dataBooks[$count] = $row;
			$count++;
		}
		
		return $dataBooks;
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */